package com.youlai.boot.system.controller;

import com.youlai.boot.system.service.LpsOrderCdjgCService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.youlai.boot.system.model.form.LpsOrderCdjgCForm;
import com.youlai.boot.system.model.query.LpsOrderCdjgCQuery;
import com.youlai.boot.system.model.vo.LpsOrderCdjgCVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youlai.boot.common.result.PageResult;
import com.youlai.boot.common.result.Result;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;

/**
 * 触动机构+C前端控制层
 *
 * @author lwb
 * @since 2025-07-14 16:21
 */
@Tag(name = "触动机构+C接口")
@RestController
@RequestMapping("/api/v1/lpsOrderCdjgCs")
@RequiredArgsConstructor
public class LpsOrderCdjgCController  {

    private final LpsOrderCdjgCService lpsOrderCdjgCService;

    @Operation(summary = "触动机构+C分页列表")
    @GetMapping("/page")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderCdjgC:query')")
    public PageResult<LpsOrderCdjgCVO> getLpsOrderCdjgCPage(LpsOrderCdjgCQuery queryParams ) {
        IPage<LpsOrderCdjgCVO> result = lpsOrderCdjgCService.getLpsOrderCdjgCPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "新增触动机构+C")
    @PostMapping
    @PreAuthorize("@ss.hasPerm('system:lpsOrderCdjgC:add')")
    public Result<Void> saveLpsOrderCdjgC(@RequestBody @Valid LpsOrderCdjgCForm formData ) {
        boolean result = lpsOrderCdjgCService.saveLpsOrderCdjgC(formData);
        return Result.judge(result);
    }

    @Operation(summary = "获取触动机构+C表单数据")
    @GetMapping("/{id}/form")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderCdjgC:edit')")
    public Result<LpsOrderCdjgCForm> getLpsOrderCdjgCForm(
        @Parameter(description = "触动机构+CID") @PathVariable Long id
    ) {
        LpsOrderCdjgCForm formData = lpsOrderCdjgCService.getLpsOrderCdjgCFormData(id);
        return Result.success(formData);
    }

    @Operation(summary = "修改触动机构+C")
    @PutMapping(value = "/{id}")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderCdjgC:edit')")
    public Result<Void> updateLpsOrderCdjgC(
            @Parameter(description = "触动机构+CID") @PathVariable Long id,
            @RequestBody @Validated LpsOrderCdjgCForm formData
    ) {
        boolean result = lpsOrderCdjgCService.updateLpsOrderCdjgC(id, formData);
        return Result.judge(result);
    }

    @Operation(summary = "删除触动机构+C")
    @DeleteMapping("/{ids}")
    @PreAuthorize("@ss.hasPerm('system:lpsOrderCdjgC:delete')")
    public Result<Void> deleteLpsOrderCdjgCs(
        @Parameter(description = "触动机构+CID，多个以英文逗号(,)分割") @PathVariable String ids
    ) {
        boolean result = lpsOrderCdjgCService.deleteLpsOrderCdjgCs(ids);
        return Result.judge(result);
    }
}
